package EventHandling;


public class Timer {

	private int startTime;
	private int endTime;
	private double elapsedTime;
	private int currentEventTime;

	public Timer() {
		this.startTime = 0;
		this.endTime = 0;
		this.elapsedTime = 0;
	}


	public int getStartTime() {
		return startTime;
	}

	public int getEndTime() {
		return endTime;
	}

	public double getElapsedTime() {
		return elapsedTime;
	}

	public void setStartTime(int startTime) {
		if (this.startTime == 0) {
			this.startTime = startTime;
			this.currentEventTime = startTime;
		} else if (startTime > this.startTime) {
			this.currentEventTime = startTime;
		}
	}

	public void setEndTime(int endTime) {
		this.endTime = endTime;
	}

	public void calculateElapsedTime() {
		double start = this.startTime;
		double end;
		if (this.endTime == 0) {	
			end = this.currentEventTime;
		} else 
			end = this.endTime; 
		
		double result = (end - start)
				;
		this.elapsedTime = result;
		
	}

	@Override
	public String toString() {
		return "Start Time: " + this.startTime + "\tCurrent Time: " + this.currentEventTime + "\tEnd Time: " + this.endTime + "\tElapsed Time: " + this.elapsedTime;
	}


}
